﻿<%@ Page Language="C#" EnableEventValidation="false" %>

<%@ Register Namespace="Antu.WebControls" Assembly="Antu.WebControls" TagPrefix="CBW" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="EluZSProvider" %>
<%@ Import Namespace="Antu.Core.Services" %>
<%
    EluZSDataProvider _EluZSDataProvider = (EluZSDataProvider)ProviderService.ProviderServiceMange.GetProvider("EluZSProvider");
    string strNian = Request.QueryString["year"];
    string strYue = Request.QueryString["month"];
    string strQS = Request.QueryString["QS"];
    DataTable dt = new DataTable();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>月征收项目报表统计查看 </title>
    <link rel="stylesheet" type="text/css" href="../../Themes/Default/Styles/basic.css" />

    <script type="text/javascript" src="../../Script/jquery.js"></script>

    <script type="text/javascript">
        function onPrint() {
            document.getElementById("div1").style.display = 'none';
            window.print();
            document.getElementById("div1").style.display = 'block';
        }
    </script>

</head>
<body>
    <div id="div1" style="width: 100%; text-align: center;">
        <img src="<%= Antu.Core.Components.SiteSettings.DefaultSiteSettings.DefaultThemeFolderMapPath %>Images/printer.png"
            align="absmiddle" onclick='window.onPrint();' style="cursor: pointer" />
        &nbsp;&nbsp;<input id="Button1" type="button" class="button" value="返回" onclick="javascript:window.location.href=('ZS_YUEBAOTJ.aspx');" />
    </div>
    <%
        if (!string.IsNullOrEmpty(strQS))
        {
            string sql = string.Format(@"Select * From (Select to_char(Rownum) 序号,(Case When 征收决定号 Is Null Then (Select 征收许可证号 From zs_prono Where Id =t.pnid) Else 征收决定号 End) 征收决定号,
(Case When 征收部门 Is Null Then (Select 征收部门 From zs_project Where Id In (Select pid From zs_prono Where Id =t.pnid)) Else 征收部门 End) 征收部门,
(Case When 征收实施单位 Is Null Then (Select 征收实施单位 From zs_project Where Id In (Select pid From zs_prono Where Id =t.pnid)) Else 征收实施单位 End) 征收实施单位,
(Case When 项目地点 Is Null Then (Select 项目地址 From zs_project Where Id In (Select pid From zs_prono Where Id =t.pnid)) Else 项目地点 End) 项目地点,
(Case When 项目名称 Is Null Then (Select 项目名称 From zs_project Where Id In (Select pid From zs_prono Where Id =t.pnid)) Else 项目名称 End) 项目名称,
to_number(nvl((Case When 居民户数 Is Null Then (Select to_char(权证户数) From zs_bcfaqs Where 补偿实施=0 and pId In (Select pid From zs_prono Where Id =t.pnid)) Else to_char(居民户数) End),0)) 年度征收总数居民权证数,
to_number(nvl((Case When 工企单位 Is Null Then (Select to_char(工企单位) From zs_bcfaqs Where 补偿实施=0 and pId In (Select pid From zs_prono Where Id =t.pnid)) Else to_char(工企单位) End),0)) 年度征收总数工企单位,
to_number(nvl((Case When 征收总面积 Is Null Then nvl((Select Round((to_number(nvl(房屋建筑面积,0))/10000),2) from zs_bcfaqs where 补偿实施=0 and pId In (Select pid From zs_prono Where Id =t.pnid)),0) Else 征收总面积 End),0)) 年度征收总数面积,
(to_char(征收期限1,'yyyy.MM.dd')||'-'||to_char(征收期限2,'yyyy.MM.dd')) 征收期限,
to_number(nvl(已搬居民户数,0)) 已搬情况居民权证数,to_number(nvl(已搬工企单位,0)) 已搬情况工企单位,to_number(nvl(已搬面积,0)) 已搬情况面积,
to_number(nvl(未搬居民户数,0)) 未搬情况居民权证数,to_number(nvl(未搬工企单位,0)) 未搬情况工企单位,to_number(nvl(未搬面积,0)) 未搬情况面积,备注
 From zs_ybbtj t Where Month='{0}' And Year='{1}' And qs In (Select keyvalue From zs_params Where Name='区属' And keyname='{2}') Order By 征收期限1 ) Union All Select '','小计','','','','',
(Select nvl(Sum(居民户数),0) From zs_ybbtj Where Month='{0}' And Year='{1}' And qs In (Select keyvalue From zs_params Where Name='区属' And keyname='{2}')),
(Select nvl(Sum(工企单位),0) From zs_ybbtj Where Month='{0}' And Year='{1}' And qs In (Select keyvalue From zs_params Where Name='区属' And keyname='{2}')),
(Select nvl(Sum(征收总面积),0) From zs_ybbtj Where Month='{0}' And Year='{1}' And qs In (Select keyvalue From zs_params Where Name='区属' And keyname='{2}')),'',
(Select nvl(Sum(已搬居民户数),0) From zs_ybbtj Where Month='{0}' And Year='{1}' And qs In (Select keyvalue From zs_params Where Name='区属' And keyname='{2}')),
(Select nvl(Sum(已搬工企单位),0) From zs_ybbtj Where Month='{0}' And Year='{1}' And qs In (Select keyvalue From zs_params Where Name='区属' And keyname='{2}')),
(Select nvl(Sum(已搬面积),0) From zs_ybbtj Where Month='{0}' And Year='{1}' And qs In (Select keyvalue From zs_params Where Name='区属' And keyname='{2}')),
(Select nvl(Sum(未搬居民户数),0) From zs_ybbtj Where Month='{0}' And Year='{1}' And qs In (Select keyvalue From zs_params Where Name='区属' And keyname='{2}')),
(Select nvl(Sum(未搬工企单位),0) From zs_ybbtj Where Month='{0}' And Year='{1}' And qs In (Select keyvalue From zs_params Where Name='区属' And keyname='{2}')),
(Select nvl(Sum(未搬面积),0) From zs_ybbtj Where Month='{0}' And Year='{1}' And qs In (Select keyvalue From zs_params Where Name='区属' And keyname='{2}')),'' From dual ", strYue, strNian, strQS);
            dt = _EluZSDataProvider.GetTable(sql);
            if (dt.Rows.Count > 0)
            {
    %>
    <table class="window_tab_list" style="border-collapse: collapse;">
        <tr style="height:30px;">
            <th colspan="17" style="font-size: 20px;">
                <% Response.Write(strQS);  %><% Response.Write(strNian);  %>年<% Response.Write(strYue);  %>月征收项目明细情况一览表
            </th>
        </tr>
        <tr style="height:25px;">
            <td rowspan="2">
                序号
            </td>
            <td rowspan="2">
                征收决定号
            </td>
            <td rowspan="2">
                征收部门
            </td>
            <td rowspan="2">
                征收实施单位
            </td>
            <td rowspan="2">
                项目地点
            </td>
            <td rowspan="2">
                项目名称
            </td>
            <td colspan="3">
                年（月）度征收总数
            </td>
            <td rowspan="2">
                征收期限
            </td>
            <td colspan="3">
                已搬情况
            </td>
            <td colspan="3">
                未搬情况
            </td>
            <td rowspan="2">
                备注
            </td>
        </tr>
        <tr style="height:25px;">
            <td>
                居民权证数
            </td>
            <td>
                工企单位
            </td>
            <td>
                面积(万m2)
            </td>
            <td>
                居民权证数
            </td>
            <td>
                工企单位
            </td>
            <td>
                面积(万m2)
            </td>
            <td>
                居民权证数
            </td>
            <td>
                工企单位
            </td>
            <td>
                面积(万m2)
            </td>
        </tr>
        <%
            for (int i = 0; i < dt.Rows.Count; i++)
            {
        %>
        <tr style="height:25px;">
            <%
                for (int j = 0; j < dt.Rows[i].ItemArray.Length; j++)
                {
            %>
            <td>
                <%
                    Response.Write(dt.Rows[i].ItemArray[j].ToString());
                %>
            </td>
            <%
                }
            %>
        </tr>
        <%
            }
        %>
    </table>
    <%
        }
        }
        else
        {
            string qsql = string.Format(@"Select Distinct t1.keyname From zs_ybbtj t,zs_params t1 
Where t.qs=t1.keyvalue And t1.Name='区属' And t.Year='{0}' And t.Month='{1}'", strNian, strYue);
            dt = _EluZSDataProvider.GetTable(qsql);
            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    string strqss = dt.Rows[i]["keyname"].ToString();
                    
    %>
    <table class="window_tab_list" style="border-collapse: collapse; margin-top:5px;">
        <tr style="height:30px;">
            <th colspan="17" style="font-size: 20px;">
                <% Response.Write(strqss);  %><% Response.Write(strNian);  %>年<% Response.Write(strYue);  %>月征收项目明细情况一览表
            </th>
        </tr>
        <tr style="height:25px;">
            <td rowspan="2">
                序号
            </td>
            <td rowspan="2">
                征收决定号
            </td>
            <td rowspan="2">
                征收部门
            </td>
            <td rowspan="2">
                征收实施单位
            </td>
            <td rowspan="2">
                项目地点
            </td>
            <td rowspan="2">
                项目名称
            </td>
            <td colspan="3">
                年（月）度征收总数
            </td>
            <td rowspan="2">
                征收期限
            </td>
            <td colspan="3">
                已搬情况
            </td>
            <td colspan="3">
                未搬情况
            </td>
            <td rowspan="2">
                备注
            </td>
        </tr>
        <tr style="height:25px;">
            <td>
                居民权证数
            </td>
            <td>
                工企单位
            </td>
            <td>
                面积(万m2)
            </td>
            <td>
                居民权证数
            </td>
            <td>
                工企单位
            </td>
            <td>
                面积(万m2)
            </td>
            <td>
                居民权证数
            </td>
            <td>
                工企单位
            </td>
            <td>
                面积(万m2)
            </td>
        </tr>
        <%
            string sql1 = string.Format(@"Select * From (Select to_char(Rownum) 序号,(Case When 征收决定号 Is Null Then (Select 征收许可证号 From zs_prono Where Id =t.pnid) Else 征收决定号 End) 征收决定号,
(Case When 征收部门 Is Null Then (Select 征收部门 From zs_project Where Id In (Select pid From zs_prono Where Id =t.pnid)) Else 征收部门 End) 征收部门,
(Case When 征收实施单位 Is Null Then (Select 征收实施单位 From zs_project Where Id In (Select pid From zs_prono Where Id =t.pnid)) Else 征收实施单位 End) 征收实施单位,
(Case When 项目地点 Is Null Then (Select 项目地址 From zs_project Where Id In (Select pid From zs_prono Where Id =t.pnid)) Else 项目地点 End) 项目地点,
(Case When 项目名称 Is Null Then (Select 项目名称 From zs_project Where Id In (Select pid From zs_prono Where Id =t.pnid)) Else 项目名称 End) 项目名称,
to_number(nvl((Case When 居民户数 Is Null Then (Select to_char(权证户数) From zs_bcfaqs Where 补偿实施=0 and pId In (Select pid From zs_prono Where Id =t.pnid)) Else to_char(居民户数) End),0)) 年度征收总数居民权证数,
to_number(nvl((Case When 工企单位 Is Null Then (Select to_char(工企单位) From zs_bcfaqs Where 补偿实施=0 and pId In (Select pid From zs_prono Where Id =t.pnid)) Else to_char(工企单位) End),0)) 年度征收总数工企单位,
to_number(nvl((Case When 征收总面积 Is Null Then nvl((Select Round((to_number(nvl(房屋建筑面积,0))/10000),2) from zs_bcfaqs where 补偿实施=0 and pId In (Select pid From zs_prono Where Id =t.pnid)),0) Else 征收总面积 End),0)) 年度征收总数面积,
(to_char(征收期限1,'yyyy.MM.dd')||'-'||to_char(征收期限2,'yyyy.MM.dd')) 征收期限,
to_number(nvl(已搬居民户数,0)) 已搬情况居民权证数,to_number(nvl(已搬工企单位,0)) 已搬情况工企单位,to_number(nvl(已搬面积,0)) 已搬情况面积,
to_number(nvl(未搬居民户数,0)) 未搬情况居民权证数,to_number(nvl(未搬工企单位,0)) 未搬情况工企单位,to_number(nvl(未搬面积,0)) 未搬情况面积,备注
 From zs_ybbtj t Where Month='{0}' And Year='{1}' And qs In (Select keyvalue From zs_params Where Name='区属' And keyname='{2}') Order By 征收期限1 ) Union All Select '','小计','','','','',
(Select nvl(Sum(居民户数),0) From zs_ybbtj Where Month='{0}' And Year='{1}' And qs In (Select keyvalue From zs_params Where Name='区属' And keyname='{2}')),
(Select nvl(Sum(工企单位),0) From zs_ybbtj Where Month='{0}' And Year='{1}' And qs In (Select keyvalue From zs_params Where Name='区属' And keyname='{2}')),
(Select nvl(Sum(征收总面积),0) From zs_ybbtj Where Month='{0}' And Year='{1}' And qs In (Select keyvalue From zs_params Where Name='区属' And keyname='{2}')),'',
(Select nvl(Sum(已搬居民户数),0) From zs_ybbtj Where Month='{0}' And Year='{1}' And qs In (Select keyvalue From zs_params Where Name='区属' And keyname='{2}')),
(Select nvl(Sum(已搬工企单位),0) From zs_ybbtj Where Month='{0}' And Year='{1}' And qs In (Select keyvalue From zs_params Where Name='区属' And keyname='{2}')),
(Select nvl(Sum(已搬面积),0) From zs_ybbtj Where Month='{0}' And Year='{1}' And qs In (Select keyvalue From zs_params Where Name='区属' And keyname='{2}')),
(Select nvl(Sum(未搬居民户数),0) From zs_ybbtj Where Month='{0}' And Year='{1}' And qs In (Select keyvalue From zs_params Where Name='区属' And keyname='{2}')),
(Select nvl(Sum(未搬工企单位),0) From zs_ybbtj Where Month='{0}' And Year='{1}' And qs In (Select keyvalue From zs_params Where Name='区属' And keyname='{2}')),
(Select nvl(Sum(未搬面积),0) From zs_ybbtj Where Month='{0}' And Year='{1}' And qs In (Select keyvalue From zs_params Where Name='区属' And keyname='{2}')),'' From dual ", strYue, strNian, strqss);
            DataTable dt1 = _EluZSDataProvider.GetTable(sql1);
            for (int k = 0; k < dt1.Rows.Count; k++)
            {
        %>
        <tr style="height:25px;">
            <%
                for (int m = 0; m < dt1.Rows[k].ItemArray.Length; m++)
                {
            %>
            <td>
                <%
                    Response.Write(dt1.Rows[k].ItemArray[m].ToString());
                %>
            </td>
            <%
                }
            %>
        </tr>
        <%
            }
        %>
    </table>
    <%
        }
            }
        }
    %>
</body>
</html>
